package com.yili.oa.dao;

import com.yili.oa.models.Admin;
import com.yili.oa.models.AdminExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface AdminMapper {
    @SelectProvider(type=AdminSqlProvider.class, method="countByExample")
    long countByExample(AdminExample example);

    @DeleteProvider(type=AdminSqlProvider.class, method="deleteByExample")
    int deleteByExample(AdminExample example);

    @Delete({
        "delete from t_admins",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into t_admins (id, username, ",
        "password, name, ",
        "create_time, parent, ",
        "token, last_login_time, ",
        "is_admin, state, ",
        "other_int, other_char, ",
        "userRole, money, room_cost, ",
        "level_id, experience)",
        "values (#{id,jdbcType=INTEGER}, #{username,jdbcType=CHAR}, ",
        "#{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=BIGINT}, #{parent,jdbcType=CHAR}, ",
        "#{token,jdbcType=CHAR}, #{lastLoginTime,jdbcType=BIGINT}, ",
        "#{isAdmin,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, ",
        "#{otherInt,jdbcType=INTEGER}, #{otherChar,jdbcType=CHAR}, ",
        "#{userrole,jdbcType=VARCHAR}, #{money,jdbcType=REAL}, #{roomCost,jdbcType=INTEGER}, ",
        "#{levelId,jdbcType=BIGINT}, #{experience,jdbcType=BIGINT})"
    })
    int insert(Admin record);

    @InsertProvider(type=AdminSqlProvider.class, method="insertSelective")
    int insertSelective(Admin record);

    @SelectProvider(type=AdminSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="username", property="username", jdbcType=JdbcType.CHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.BIGINT),
        @Result(column="parent", property="parent", jdbcType=JdbcType.CHAR),
        @Result(column="token", property="token", jdbcType=JdbcType.CHAR),
        @Result(column="last_login_time", property="lastLoginTime", jdbcType=JdbcType.BIGINT),
        @Result(column="is_admin", property="isAdmin", jdbcType=JdbcType.INTEGER),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="other_int", property="otherInt", jdbcType=JdbcType.INTEGER),
        @Result(column="other_char", property="otherChar", jdbcType=JdbcType.CHAR),
        @Result(column="userRole", property="userrole", jdbcType=JdbcType.VARCHAR),
        @Result(column="money", property="money", jdbcType=JdbcType.REAL),
        @Result(column="room_cost", property="roomCost", jdbcType=JdbcType.INTEGER),
        @Result(column="level_id", property="levelId", jdbcType=JdbcType.BIGINT),
        @Result(column="experience", property="experience", jdbcType=JdbcType.BIGINT)
    })
    List<Admin> selectByExample(AdminExample example);

    @Select({
        "select",
        "id, username, password, name, create_time, parent, token, last_login_time, is_admin, ",
        "state, other_int, other_char, userRole, money, room_cost, level_id, experience",
        "from t_admins",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="username", property="username", jdbcType=JdbcType.CHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.BIGINT),
        @Result(column="parent", property="parent", jdbcType=JdbcType.CHAR),
        @Result(column="token", property="token", jdbcType=JdbcType.CHAR),
        @Result(column="last_login_time", property="lastLoginTime", jdbcType=JdbcType.BIGINT),
        @Result(column="is_admin", property="isAdmin", jdbcType=JdbcType.INTEGER),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER),
        @Result(column="other_int", property="otherInt", jdbcType=JdbcType.INTEGER),
        @Result(column="other_char", property="otherChar", jdbcType=JdbcType.CHAR),
        @Result(column="userRole", property="userrole", jdbcType=JdbcType.VARCHAR),
        @Result(column="money", property="money", jdbcType=JdbcType.REAL),
        @Result(column="room_cost", property="roomCost", jdbcType=JdbcType.INTEGER),
        @Result(column="level_id", property="levelId", jdbcType=JdbcType.BIGINT),
        @Result(column="experience", property="experience", jdbcType=JdbcType.BIGINT)
    })
    Admin selectByPrimaryKey(Integer id);

    @UpdateProvider(type=AdminSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Admin record, @Param("example") AdminExample example);

    @UpdateProvider(type=AdminSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Admin record, @Param("example") AdminExample example);

    @UpdateProvider(type=AdminSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Admin record);

    @Update({
        "update t_admins",
        "set username = #{username,jdbcType=CHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=BIGINT},",
          "parent = #{parent,jdbcType=CHAR},",
          "token = #{token,jdbcType=CHAR},",
          "last_login_time = #{lastLoginTime,jdbcType=BIGINT},",
          "is_admin = #{isAdmin,jdbcType=INTEGER},",
          "state = #{state,jdbcType=INTEGER},",
          "other_int = #{otherInt,jdbcType=INTEGER},",
          "other_char = #{otherChar,jdbcType=CHAR},",
          "userRole = #{userrole,jdbcType=VARCHAR},",
          "money = #{money,jdbcType=REAL},",
          "room_cost = #{roomCost,jdbcType=INTEGER},",
          "level_id = #{levelId,jdbcType=BIGINT},",
          "experience = #{experience,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Admin record);
}